
#include "stdio.h"
#include <stdint.h>
#include "../section_locate.h"
void overflow_test(void);

static char name[30] = "overflow_test";
struct func_pack sec_overflow_test __attribute__ ( ( section ( "func_area" ) ) ) = {
    .func_addr = overflow_test,
	.name_str = (uint32_t *)&name,
};
//void overflow_test(void)
//{
//
//    uint16_t current_tick = 5;
//    uint16_t start_tick = 0;
//    uint16_t interval = 2;
//
//    printf("input start_tick:\n");
//	scanf("%hd", &start_tick);
//
//	printf("input current_tick:\n");
//	scanf("%hd", &current_tick);
//
//	printf("input interval:\n");
//	scanf("%hd", &interval);
//	printf("start_tick = %hd\n", start_tick);
//	int16_t tmp = ( current_tick - start_tick );
//	printf("tmp = %d\n", tmp);
//	int16_t expired = tmp >= ( int16_t ) interval;
//	printf("expired = %d\n", expired);
//}

#define time_after(unknown, known)  ( (int16_t)(known) - (int16_t)(unknown) < 0)

void overflow_test(void)
{
    uint16_t current_tick = 5;
    uint16_t start_tick = 0;
    uint16_t interval = 2;

    printf("input start_tick:\n");
	scanf("%hd", &start_tick);

	printf("input current_tick:\n");
	scanf("%hd", &current_tick);

	printf("input interval:\n");
	scanf("%hd", &interval);
	printf("start_tick = %hd\n", start_tick);
	printf("current_tick = %hd\n", current_tick);
	int16_t tmp = (int16_t)(start_tick) - (int16_t)(current_tick);
	printf("tmp = %d\n", tmp);
	int16_t expired = tmp < 0;
	printf("expired = %d\n", expired);
}


